<ui:composition
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
	xmlns:f="http://xmlns.jcp.org/jsf/core"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
	template="/WEB-INF/templates/default.xhtml"
	xmlns:pe="http://primefaces.org/ui"
>

	<f:metadata>
		<f:viewParam
			name="bulletinId"
			value="#{bulletinHome3.id}"
		></f:viewParam>
		<f:event
			listener="#{bulletinHome3.initConversation()}"
			type="preRenderView"
		></f:event>
	   	<f:viewParam name="moduleName" value="公告审核"></f:viewParam>
	   	
	   	<f:event listener="#{bulletinHome3.suggestTime()}"
			type="preRenderView"></f:event>
	</f:metadata>
	<ui:define name="head">
		<style type="text/css">
			.removeButton {
				float: right;
				margin-right: 20px;
			}
			
			.limitUnit {
				margin-top: 5px;
			}
			h2{
   				text-align:center
   			}
   			.rowStyle{
	   			text-align: center;
	   			font-size:16px
   			}
		</style>
	</ui:define>
	<ui:define name="content">

		<h:form id="editForm">
			<p:panel
				id="panel"
				header="公告基本信息"
				style="margin-bottom:10px;"
			>
				<p:messages id="messages" closable="true">
		       		<p:autoUpdate />
		       	</p:messages>
				<ui:include src="../template/include/bulletinInfo.xhtml">
					<ui:param name="hideTime" value="true" />
				</ui:include>
			</p:panel>
			
			<p:panel>
				<h:panelGrid columns="4" width="100%">
					<p:outputLabel for="endingApplyTime" value="截止报名时间"></p:outputLabel>
					<p:calendar id="endingApplyTime"
						widgetVar="endingApplyTime"
						value="#{bulletinHome3.endingApplyTime}" 
						required="true"
						pattern="yyyy-MM-dd HH:mm" 
						locale="zh_CN"
						inputStyleClass="input-middle" 
						showOn="button"
						readonlyInput="true" />
						
					<p:outputLabel for="chooseTime" value="选取时间"></p:outputLabel>
					<p:calendar id="chooseTime"
						widgetVar="chooseTime"
						value="#{bulletinHome3.chooseTime}" 
						required="true"
						pattern="yyyy-MM-dd HH:mm" 
						locale="zh_CN"
						inputStyleClass="input-middle" 
						showOn="button"
						readonlyInput="true" />
				</h:panelGrid>
			</p:panel>
			
			<ui:include src="../template/include/bulletinReqInfo.xhtml" />
			<p:panel
				id="photos"
				header="交易申请表"
				style="margin-bottom:10px;"
						>
					<div id="imgsPreview" >
						<p:repeat
							var="_photo"
							value="#{bulletinHome3.instance.photos}"
						>
							<img  data-original="#{attachmentUtils.getFullPath(_photo)}" src="#{attachmentUtils.getFullPath(_photo)}"  width="240"/>
						</p:repeat>
					</div>	
				</p:panel>
			<p:panel header="相关附件">	
				 	<ui:include src="/WEB-INF/templates/include/bulletinAttachments.xhtml" />
			</p:panel>
			
			<p:panel
				id="selecteSupplier"
				header="已选取的中介"
				rendered="#{not empty bulletinHome3.instance.successTrade}"
				style="margin-bottom:10px;"
			>
				<p:outputLabel
					for="supplier"
					value="中介名称："
					style="margin:5px 10px"
				></p:outputLabel>
				<h:outputText
					id="supplier"
					value="#{bulletinHome3.instance.successTrade.supplier.cnname}"
				/>
			</p:panel>
			<ui:remove><p:panel
				id="backupSuppliers"
				header="备选中介"
				rendered="#{not empty bulletinHome3.instance.backupTrades}"
				style="margin-bottom:10px;"
			>
				<p:outputLabel
					for="backupSupplier"
					value="备选中介名称："
					style="margin:5px 10px"
				></p:outputLabel>
				<h:outputText
					id="backupSupplier"
					value="#{bulletinHome3.instance.getBackUpSupplierNames()}"
				/>
			</p:panel>
			</ui:remove>
			
			<ui:remove>
				<p:commandButton value="查看可报名的中介" oncomplete="PF('suppliersDialog').show()" update="suppliersDialog" action="#{bulletinHome3.initSuppliers()}" >
				</p:commandButton>	
			</ui:remove>
			<p:remoteCommand  name="showSuppliers" actionListener="#{bulletinChooseContoller.getSupplierByBulletinId()}" />	 
			<p:commandButton value="查看可报名的中介"  onclick="showSuppliers([{name:'bulletinId', value:'#{bulletinHome3.id}'}]);PF('suppliersDialog1').show()"  type="button">
			</p:commandButton>
			<p:commandButton
				action="#{bulletinHome3.audit}"
				value="审核通过"
				ajax="false"
				rendered="#{empty bulletinHome3.instance.auditResult}"
			/>			
			<p:commandButton
				oncomplete="PF('rejectDialog').show();"
				value="驳回"
				immediate="true"
			></p:commandButton>
			<p:commandButton
				action="#{bulletinHome3.unaudit()}"
				value="取消发布"
				immediate="true"
				rendered="#{not empty bulletinHome3.instance.auditResult and  bulletinHome3.instance.auditResult}"></p:commandButton>
			<p:commandButton
				action="#{bulletinHome3.cancel()}"
				value="取消"
				immediate="true"
			></p:commandButton>
		</h:form>

		<p:dialog
			id="rejectDialog"
			widgetVar="rejectDialog"
		>
			<f:facet name="header">
				驳回原因
			</f:facet>
			<h:form>
				<p:panelGrid columns="2">
					<p:outputLabel
						for="reason"
						value="驳回原因"
					></p:outputLabel>
					<p:inputTextarea
						id="reason"
						value="#{rejectRecordHome.instance.reason}"
						required="true"
						cols="80"
						rows="5"
					></p:inputTextarea>
				</p:panelGrid>

				<p:commandButton
					action="#{bulletinHome3.reject()}"
					value="驳回"
					ajax="false"
				/>
				<p:commandButton
					oncomplete="PF('rejectDialog').hide();"
					value="取消"
					immediate="true"
				></p:commandButton>
			</h:form>
		</p:dialog>
		
		
		<ui:remove>
			<p:dialog id="suppliersDialog" widgetVar="suppliersDialog" height="400" >
				<h2>共<font color="red">#{bulletinHome3.suppliers.size()}</font>家中介可收到邀请</h2>
				<ul>
					<p:repeat var="_supplier"  value="#{bulletinHome3.suppliers}">
						<li>
							#{_supplier.cnname}
						</li>	
					</p:repeat>
				</ul>	
			</p:dialog>
		</ui:remove>
		
		
		<p:dialog id="suppliersDialog1" widgetVar="suppliersDialog1" height="400" >
			<h2>共<font color="red">#{bulletinChooseContoller.suppliers.size()}</font>家中介可收到邀请</h2>
			<ul>
				<p:repeat var="_supplier"  value="#{bulletinChooseContoller.suppliers}">
					<li>
						#{_supplier.cnname}
					</li>	
				</p:repeat>
			</ul>	
		</p:dialog>
		
	</ui:define>
</ui:composition>
